package com.zjdiepu.www.rest.api.base;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.common.consts.SystemConsts;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.base.request.DataDictRequest;
import com.zjdiepu.www.util.CachedEnums;

/**
 * 所属公司：稻普控股集团
 * 项目名称：dpqc-parent-manager-dictionaries
 * 类名称：DataDictionaryController
 * 类描述：
 * 创建人：winby
 * 创建时间：2017年4月5日15:57:49
 * 修改人：winby
 * 修改时间：2017年4月5日15:57:49
 * 修改备注：
 *
 * @version V1.0
 */
@RestController
@RequestMapping(value= "DataDictionaryController", produces="application/json;charset=UTF-8", method = RequestMethod.POST)
@Api(tags = {"数据字典"}, produces="application/json;charset=UTF-8")
public class DataDictionaryController extends BaseController {
    @Resource
    private ICachedDictionaryService cachedDictionaryService;

    /**
     * @author xiongxiaotun
     * @Title: dataDictList  <br/>
     * @Description: 数据字典 <br/>
     * @param dpBaseDataDictionary
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "数据字典", response = SimpleDataDictionary.class, httpMethod="POST")
    @ApiImplicitParams({ //还款状态、当前逾期金额
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "dataDictList")
    public ApiResponse dataDictList(@Validated @RequestBody DataDictRequest dataDictRequest) {
    	String parentValue = dataDictRequest.getParentValue();
    	DataDicType dataDicType = CachedEnums.getByCode(parentValue, DataDicType.class);
    	List<SimpleDataDictionary> simpleDataDictionarys = cachedDictionaryService.getCachedDataDics(dataDicType);
        return ApiResponse.success(simpleDataDictionarys);
    }
}
